import { DiscordSnowflake } from 'discordoo'
import { BeforeInsert, PrimaryColumn } from 'typeorm'

export abstract class DiscordID {
  @PrimaryColumn()
  declare id: string

  @BeforeInsert()
  private beforeInsert() { // if id is not set, generate a new one
    this.id = DiscordSnowflake.generate(Date.now(), process.ppid ?? 0, process.pid)
  }
}